package com.example.demo.net;

import lombok.Data;

/**
 * 网络节点{@link NetNode}统一返回值
 *
 * @author ZheMing Liu
 * @since 2021.11.5
 */
@Data
public class NetResponse<T> {
	private static final long serialVersionUID = 1L;

	private Integer code;
	private String msg;
	private T data;


	public static NetResponse fail(Integer code,String msg) {
		NetResponse responseVo = new NetResponse();
		responseVo.setCode(code);
		responseVo.setMsg(msg);
		return responseVo;
	}

	public static <T> NetResponse<T> ok(Integer code,String msg,T data) {
		NetResponse responseVo = new NetResponse();
		responseVo.setCode(code);
		responseVo.setData(data);
		responseVo.setMsg(msg);
		return responseVo;
	}
}
